<template>
    <div class="productProNew">
        <div class="title"><h1><span>紧急通知</span></h1></div>
        <form name="notice" class="basicInfor">
            <h1 class="hide">紧急内容(必填)</h1>
            <div class="form-group required">
                <label class="destxt" :for="'announce'+$attrs.text">内容：</label>
                <textarea class="form-control proDes" :id="'announce'+$attrs.text" rows="6" placeholder="请输入内容" maxlength="250"  @input="countChar" v-model="msg"></textarea>
                <span id="counter">{{num}}/250</span>
            </div>
            <button type="button" class="btn btn-info confirmBtn" @click="confirmBtn()">确定</button>
        </form>
    </div>
</template>
<script>
    export default {
        data(){
            return{
                MsgHttp:'',
                num:0,
                msg:'',
                Msgid:'',
            }
        },
        computed:{
            BaseList(){
                return this.$store.state.interface.xchBaseList;
            },
            setXchMsg(){
                return this.$store.state.interface.setXchMsg;
            },
        },
        beforeMount(){
            let url = this.BaseList;
            let sessionId = JSON.parse(sessionStorage.getItem('customer')).sid;
            let Http = url+'?sid='+sessionId; //
            this.MsgHttp = this.setXchMsg+'?sid='+sessionId; //修改
        },
        methods:{
            countChar(){
                this.num = this.msg.length;
            },
            confirmBtn(){
                let self = this;
                if (self.msg === '') {
                  layer.msg('请填写通知内容!');
                  return false
                }
                self.$ajax.post(self.MsgHttp+'&xid='+self.$attrs.proid+'&msg='+self.msg).then(function(res){
                    let code = res.data.code;
                    if(code === '10000'){
                        layer.msg('修改成功!');
                    } else {
                        self.codes(code);
                        layer.msg('修改失败!');
                    }
                },function(res){
                    layer.msg('服务器错误!');
                })
            },

        },
        mounted(){
            this.msg=this.$attrs.proSn;
        }
    }
</script>
<style lang="scss" scoped>
    .form-group{

        #counter{
            margin-left: -60px;
            top: -10px;
            position: relative;
        }
    }


</style>
